<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<%@ page import="database_layer.*" %>
<%@ page import="interface_layer.*" %>
<%@ page errorPage="exceptionPage.jsp" %>
<%-- 
	This JSP includes the form which adds a course to the system.
	It has its own JS file which checks for validation. Of course, only an
	administrator can access this page.
 --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
<link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/courseFormValidation.js"></script>
<title>Course addition</title>
</head>
<body>
<jsp:include page="header_part_1.html"/>
            <div id="templatemo_menu">
                <ul>
                    <li><a href="index.jsp">Home</a></li>
                    <li><a href="about.jsp">About Us</a></li>
<%
                    	String username = (String) session.getAttribute("username");
                        if (null != username)
                        {
%>
                            <li><a href="userPage.jsp">Your profile</a></li>
                    <li><a href="allCourses.jsp" class="current">Courses</a></li>
                    <li><a href="allUsers.jsp">Users</a></li>
<%
                        }
%>
                </ul>    	
            </div> <!-- end of templatemo_menu -->
<jsp:include page="header_part_2.html"/>
<div id="content">
<%
	String userType = (String) session.getAttribute("userType");

	if (null == username || null == userType)
	{
		/* Not logged in = Not authorized */
		ErrorHandler.parseForErrors(Common.UNAUTHORIZED_OPERATION, response, null);
		return;
	}
	
	if (!userType.equals(Common.adminType))
	{
		/* Not an admin... */
		ErrorHandler.parseForErrors(Common.UNAUTHORIZED_OPERATION, response, null);
		return;
	}
%>

<h3>Add a new course</h3>
<form name="courseForm" id="courseForm" onsubmit="return checkCourseForm()" 
      method="post" action="courseAddition">
		<u><b>Course details</b></u><br/><br/>
		<div class="row">
			<label class="registerLabel" for="Course Name">Course Name:</label> 
			<input class="registerInputBox" name="Course name" type="text" />
		</div>
		<div class="row">
			<label class="registerLabel" for="Description">Description:</label> 
			<textarea class="registerInputBox" name="Description"></textarea>
		</div>
		<div class="row">
			<label class="registerLabel" for="Credit points">Credit points:</label> 
			<input class="registerInputBox" name="Credit points" type="text" />
		</div>
		<div class="row">
			<label class="registerLabel" for="Student capacity">Student Capacity:</label>
			&nbsp;&nbsp; 
			<input class="registerInputBox" name="Student capacity" type="text" />
		</div>
		<div class="row">
			<label class="registerLabel" for="Group number">Group number:</label>
			 <input class="registerInputBox" name="Group Number" type="text" />
		</div>
		<br/>
<% for (int i = 0 ; i < 5 ; i++) { %>
	<p>
		<b>Session details</b><br/>
		<select name="<%= "day_" + i %>">
			<option value="0">Please choose a day...</option>
			<option value="1">Sunday</option>
			<option value="2">Monday</option>
			<option value="3">Tuesday</option>
			<option value="4">Wednesday</option>
			<option value="5">Thursday</option>
			<option value="6">Friday</option>
			<option value="7">Saturday</option>
		</select><br/>
		<select name="<%= "starting_time_" + i %>">
			<option value="0">Please choose the starting time...</option>
			<option value="8">8:00</option>
			<option value="9">9:00</option>
			<option value="10">10:00</option>
			<option value="11">11:00</option>
			<option value="12">12:00</option>
			<option value="13">13:00</option>
			<option value="14">14:00</option>
			<option value="15">15:00</option>
			<option value="16">16:00</option>
			<option value="17">17:00</option>
		</select><br/>
		<select name="<%= "duration_" + i %>">
			<option value="0">Please choose a duration</option>
			<option value="1">1 hour</option>
			<option value="2">2 hours</option>
			<option value="3">3 hours</option>
			<option value="4">4 hours</option>
		</select><br/>
	</p>
<% } %>
	<input type="submit" value="Add the course" />
</form>
</div>
<jsp:include page="sidebar.jsp"/>
<jsp:include page="footer.html"/>
</body>
</html>